<template>
  <div>
    <div class="flex flex-col h-full">
      <SearchContainer @search="getData" @reset="() => formRef.resetFields()">
        <a-form ref="formRef" class="form-style-flex" :model="formState" :colon="false">
          <a-form-item name="zjm" label="" class="ml-2 w-[280px]">
            <a-input v-model:value="formState.zjm" placeholder="项目名称/姓名/助记码" allow-clear />
          </a-form-item>
          <a-form-item name="dateRange" label="入账日期" class="w-[320px] ml-4 mr-5">
            <a-range-picker v-model:value="formState.dateRange" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
          </a-form-item>
          <a-form-item name="lb" label="" class="w-[320px]">
            <a-radio-group v-model:value="formState.lb" value="1">
              <!-- <a-radio :value="1">全部</a-radio>
              <a-radio :value="2">门诊</a-radio> -->
              <a-radio :value="1">住院</a-radio>
            </a-radio-group>
          </a-form-item>
        </a-form>
      </SearchContainer>
      <a-card class="mt-2">
        <div class="flex justify-end mb-3">
          <BaseExport type="手术统计" name="使用查询" code="000856" :search-params="{ ...formState, lb: '' }">导出</BaseExport>
        </div>
        <BaseTable :loading="loading" column-code="000856" fill :data-source="tableData" bordered :pagination="pagination">
          <template #bodyCell="{ column, index, record }">
            <template v-if="column.dataIndex === 'xh'">
              {{ index + 1 }}
            </template>
            <template v-if="column.dataIndex === 'brName'">
              <MedicineInfo :value="{ mc: record.brName, gg: record.brXb, cj: record.brAge }" />
            </template>
          </template>
        </BaseTable>
      </a-card>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import dayjs from 'dayjs'
// import { message } from 'ant-design-vue'
import SearchContainer from '@/components/SearchContainer'
import BaseTable from '@/components/BaseTable'

const formRef = ref(null)
const formState = ref({
  dateRange: [dayjs().subtract(20, 'day').format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')],
  lb: 1
})
const { loading, tableData, getData, pagination } = useTable({
  url: '/oprOperation/opr/getUseQueryList',
  immediate: true,
  formatParams: () => {
    return {
      stdate: formState.value.dateRange?.[0],
      eddate: formState.value.dateRange?.[1],
      zjm: formState.value.zjm,
      lb: ''
    }
  }
})
</script>
